package org.i77soft.games.LGame.engine;

import org.loon.framework.android.game.core.graphics.LImage;
import org.loon.framework.android.game.core.graphics.device.LGraphics;

public class Images {

    public Images() {
    }

    public static LImage load(String imageName) {
        return LImage.createImage("assets" + imageName);
    }

    public static LImage[][] cut(String imageName, int sliceWidth,
            int sliceHeight) {
        LImage sheet = LImage.createImage("assets" + imageName);
        int w = sheet.getWidth();
        int h = sheet.getHeight();
        int xSlices = w / sliceWidth;
        int ySlices = h / sliceHeight;
        LImage images[][] = new LImage[xSlices][ySlices];
        for (int x = 0; x < xSlices; x++) {
            for (int y = 0; y < ySlices; y++) {
                LImage img = new LImage(sliceWidth, sliceHeight, true);
                LGraphics g = img.getLGraphics();
                g.drawImage(sheet, -x * sliceWidth, -y * sliceHeight);
                g.dispose();
                images[x][y] = img;
            }
        }
        return images;
    }
}